package com.alks.function.mapper.chengKong;

import com.alks.entity.data.entity.*;
import com.alks.function.data.dto.chengKong.produce.*;
import com.alks.function.data.request.chengKong.LotNoToStyleRequest;
import com.alks.function.data.request.chengKong.OutGoingNumberQueryRequest;
import com.alks.function.data.request.chengKong.OutGoingQueryRequest;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

public interface PcOutListMapper {

    /**
     * 外发项目建档-外加工项目明细
     * @return
     */
    @Select("select PART_NAME,PART_SEQ,S_SURPLUS_FLAG from PC_OUT_LIST order by PART_SEQ asc")
    List<PcOutListDto> getOutsourcedProjectsList();

    /**
     * 添加外加工项目
     * @param pcOutList
     */
    @Insert("INSERT INTO PC_OUT_LIST (COMPANY_ID, PART_NAME, SYS_DATE, SYS_USER, S_SURPLUS_FLAG)" +
            "VALUES (#{companyId}, #{partName}, #{sysDate}, #{sysUser}, #{sSurplusFlag})")
    void AddOutsourcedProjectsAdd(PcOutList pcOutList);

    /**
     * 修改是否预补
     * @param userName
     * @param dateTime
     * @param value
     * @param partSeq
     */
    @Update("update PC_OUT_LIST set SYS_USER=#{userName},SYS_DATE=#{dateTime},S_SURPLUS_FLAG=#{value} where PART_SEQ=#{partSeq}")
    void UpdateOutsourcedProjects(@Param("userName") String userName,
                                     @Param("dateTime") LocalDateTime dateTime,
                                     @Param("value") String value,
                                     @Param("partSeq") Integer partSeq);

    /**
     * 删除外加工项目
     * @param partSeq
     */
    @Delete("delete from PC_OUT_LIST where PART_SEQ=#{partSeq}")
    void delOutsourcedProjects(Integer partSeq);

    /**
     * 查询外发项目列表
     * @param request
     */
    @Select({
            "<script>",
            "select LOT_NO, STYLE, ORDER_QTY from PC_LOT_HEAD",
            "<where>",
            "and COMPANY_ID=#{companyId}",
            "<if test='lotNo!=null and !lotNo.isEmpty()'>",
            " and LOT_NO LIKE concat('%',#{lotNo},'%')",
            "</if>",
            "<if test='style!=null and !style.isEmpty()'>",
            "and STYLE LIKE concat('%',#{style},'%')",
            "</if>",
            "</where>",
            "</script>"
    })
    List<PcLotHeadListDto> getPcLotHeadList(LotNoToStyleRequest request);

    /**
     * 查询指令信息
     * @param lotNo
     * @param companyId
     * @return
     */
    @Select("select LOT_NO,STYLE,COLOR,ORDER_QTY from PC_LOT_HEAD where LOT_NO=#{lotNo} and COMPANY_ID=#{companyId}")
    PcLotHead getPcLotHead(String lotNo, String companyId);

    /**
     * 查询图片
     * @param style
     * @param color
     * @param companyId
     * @return
     */
    @Select("select PHOTO_PATH from SD_STYLE_COLOR_PHOTO where STYLE_NO=#{style} AND STYLE_COLOR=#{color} and COMPANY_ID=#{companyId} ")
    String getPhoto(@Param("style") String style,
                    @Param("color") String color,
                    @Param("companyId") String companyId);

    /**
     * 查询号码明细
     *
     * @param lotNo
     * @param partName
     * @param companyId
     */
    @Select({
            "<script>",
            "SELECT t4.PART_NAME,t1.LOT_NO,t1.STYLE,t2.SEQ_NO,t2.SIZE_NO,t3.CUT_SIZE,t2.ORDER_QTY,t2.SURPLUS_QTY," +
                    "CASE WHEN t4.S_SURPLUS_FLAG='Y' THEN 1 ELSE 0 END as subSurplusFlag,t5.QTY,CASE " +
                    "        WHEN CASE WHEN t4.S_SURPLUS_FLAG='Y' THEN 0 ELSE 1 END = 0 " +
                    "        THEN COALESCE(t2.ORDER_QTY, 0)  + COALESCE(t2.SURPLUS_QTY, 0) " +
                    "        ELSE COALESCE(t2.ORDER_QTY, 0) END AS totalQty, CASE" +
                    " WHEN CASE WHEN t4.S_SURPLUS_FLAG='Y' THEN 0 ELSE 1 END = 0 THEN COALESCE(t2.ORDER_QTY, 0)  + COALESCE(t2.SURPLUS_QTY, 0) -COALESCE(t5.QTY, 0)" +
                    " ELSE COALESCE(t2.ORDER_QTY, 0)-COALESCE(t5.QTY, 0) END AS outQty\n" +
                    " FROM PC_OUT_LIST t4 LEFT JOIN PC_OUT_LIST_PRICE t1 on t1.PART_NAME=t4.PART_NAME LEFT JOIN PC_LOT_DETAIL t2 on t1.LOT_NO=t2.LOT_NO " +
                    " LEFT JOIN SD_STYLE_SIZE t3 on t3.SIZE_NO=t2.SIZE_NO and t1.STYLE=t3.STYLE_NO AND t2.COMPANY_ID=t3.COMPANY_ID " +
                    " LEFT JOIN (SELECT SIZE_NO,LOT_NO,PROCESS,PART_NAME,SEQ_NO,SUM(QTY) AS QTY from PC_OUT_LIST_DETAIL_SIZE GROUP BY SIZE_NO,LOT_NO,PROCESS,PART_NAME) t5 " +
                    "on t1.LOT_NO=t5.LOT_NO and t1.PART_NAME=t5.PART_NAME and t5.SIZE_NO=t2.SIZE_NO " +
                    " where t1.LOT_NO=#{lotNo} and t4.PART_NAME=#{partName} and  t1.CHECK_FLAG='Y' and t1.COMPANY_ID=#{companyId} and CASE WHEN CASE WHEN t4.S_SURPLUS_FLAG='Y' THEN 0 ELSE 1 END = 0 " +
                    " THEN COALESCE(t2.ORDER_QTY, 0)  + COALESCE(t2.SURPLUS_QTY, 0) -COALESCE(t5.QTY, 0) " +
                    " ELSE COALESCE(t2.ORDER_QTY, 0)-COALESCE(t5.QTY, 0) END >0 ORDER BY t4.PART_NAME,t1.LOT_NO,t2.SEQ_NO asc",
            "</script>",
    })
    List<PcOutSizeListDto> getSizeDetailList(@Param("lotNo") String lotNo, @Param("partName") String partName, @Param("companyId") String companyId);

    @Select("SELECT MAX(SUBSTRING(REQ_NO, 5)) FROM PC_OUT_LIST_DETAIL WHERE REQ_NO LIKE concat(#{value},'%')")
    String getReqNo(String value);

    /**
     * 添加外发明细
     * @param pcOutListDetail
     */
    @Insert("INSERT INTO PC_OUT_LIST_DETAIL(COMPANY_ID, SLIP_NO, PUR_DATE, VENDOR, LOT_NO, STYLE, COLOR, SEQ_NO, PROCESS, PART_NAME, SYS_DATE, SYS_USER," +
            "REQ_NO, PUR_QTY, PUR_MEMO, DELIVERY_DATE, CFM_FLAG, CFM_DATE, CFM_USER, PRICE, AMT, FINANCE_FLAG, FINANCE_DATE," +
            "FINANCE_USER, CUT_NUM, FINANCE_YYMM, ACCOUNT_NAME, BALANCE_NO, OUT_DISPATCH_TYPE, SUB_SURPLUS_FLAG)" +
            "VALUES" +
            "(#{companyId}, #{slipNo}, #{purDate}, #{vendor}, #{lotNo}, #{style}, #{color}, #{seqNo}, #{process}, #{partName}," +
            "#{sysDate}, #{sysUser}, #{reqNo}, #{purQty}, #{purMemo}, #{deliveryDate}, #{cfmFlag}, #{cfmDate}, #{cfmUser}," +
            "#{price}, #{amt}, #{financeFlag}, #{financeDate}, #{financeUser}, #{cutNum}, #{financeYymm}, #{accountName}," +
            "#{balanceNo}, #{outDispatchType}, #{subSurplusFlag})")
    void addPcOutListDetail(PcOutListDetail pcOutListDetail);

    /**
     * 添加外发号码明细
     * @param list
     */
    @Insert({
            "<script>",
            " INSERT INTO PC_OUT_LIST_DETAIL_SIZE(COMPANY_ID, LOT_NO, PROCESS, PART_NAME, SIZE_NO, QTY, SEQ_NO, REQ_NO, LS_NO, SLIP_NO, SURPLUS_QTY)" +
             "VALUES" +
            "<foreach collection='list' item='t' separator=','>",
                    "(#{t.companyId}, #{t.lotNo}, #{t.process}, #{t.partName}, #{t.sizeNo}, #{t.qty}, #{t.seqNo}, #{t.reqNo}, #{t.lsNo}, #{t.slipNo},#{t.surplusQty})",
            "</foreach>",
            "</script>"
    })
    void addPcOutListDetailSize(@Param("list") List<PcOutListDetailSize> list);

    /**
     * 外发明细
     * @param request
     * @param loginName
     * @param companyId
     */
    @Select({
            "<script>",
            "select t2.ORDER_QTY,t.COMPANY_ID,t.SYS_USER,t.ID,t.LOT_NO,t.STYLE,t.COLOR,t.PROCESS,t.PART_NAME,t.PUR_QTY,t.SLIP_NO,t.PUR_DATE,t.VENDOR," +
                    "t.DELIVERY_DATE,t.PRICE,AMT,t.PUR_MEMO,t.CFM_FLAG,t.REQ_NO,t.OUT_DISPATCH_TYPE,t.SUB_SURPLUS_FLAG,t.CUT_NUM from PC_OUT_LIST_DETAIL t " +
                    "LEFT JOIN PC_LOT_HEAD t2 ON t.COMPANY_ID=t2.COMPANY_ID and t.LOT_NO=t2.LOT_NO",
            "<where>",
            "t.COMPANY_ID=#{companyId} and t.SYS_USER=#{loginName}",
            "<if test='t.lotNo != null and !t.lotNo.isEmpty()'>",
            "AND t.LOT_NO LIKE CONCAT('%',#{t.lotNo},'%') ",
            "</if>",
            "<if test='t.style != null and !t.style.isEmpty()'>",
            "AND t.STYLE LIKE CONCAT('%',#{t.style},'%') ",
            "</if>",
            "<if test='t.vendor != null and !t.vendor.isEmpty()'>",
            "AND t.VENDOR LIKE CONCAT('%',#{t.vendor},'%') ",
            "</if>",
            "<if test='t.slipNo != null and !t.slipNo.isEmpty()'>",
            "AND t.SLIP_NO LIKE CONCAT('%',#{t.slipNo},'%') ",
            "</if>",
            "<if test='t.purDateStart != null'>",
            " AND t.PUR_DATE &gt;= #{t.purDateStart} ",
            "</if>",
            "<if test='t.purDateEnd != null'>",
            " AND t.PUR_DATE &lt;= #{t.purDateEnd} ",
            "</if>",
            "<if test='t.status != null and t.status==0'>",
            " AND t.SLIP_NO is null  ",
            "</if>",
            "<if test='t.status != null and t.status==1'>",
            " AND t.SLIP_NO is not null  ",
            "</if>",
            "<if test='t.outDispatchType != null '>",
            " AND t.OUT_DISPATCH_TYPE=#{t.outDispatchType} ",
            "</if>",
            "</where>",
            "</script>",
    })
    List<PcOutListDetailDto> getOutsourcedDetailsList(@Param("t") OutGoingQueryRequest request,@Param("loginName") String loginName,@Param("companyId") String companyId);

    /**
     * 外发号码明细
     * @param request
     */
    @Select("SELECT t1.SEQ_NO,t1.SIZE_NO,t2.CUT_SIZE,t1.QTY,t1.LS_NO from PC_OUT_LIST_DETAIL_SIZE t1 LEFT JOIN SD_STYLE_SIZE t2 on t1.SIZE_NO=t2.SIZE_NO AND t1.COMPANY_ID=t2.COMPANY_ID " +
            "WHERE t1.LOT_NO=#{lotNo} and t2.STYLE_NO=#{style} and t1.PART_NAME=#{partName} and t1.REQ_NO=#{reqNo} and t1.COMPANY_ID=#{companyId} ORDER BY t1.LS_NO,t1.SEQ_NO asc")
    List<PcOutDetailSizeDto> getOutsourcedNumberDetailsList(OutGoingNumberQueryRequest request);

    /**
     * 形成外加工单
     * @param updateList
     */
    @Update({
            "<script>",
            "<foreach item='t' collection='updateList' separator=';'>",
            "update PC_OUT_LIST_DETAIL set SLIP_NO=#{t.slipNo},DELIVERY_DATE=#{t.deliveryDate} where ID=#{t.id}",
            "</foreach>",
            "</script>"
    })
    void updatePcOutListDetail(@Param("updateList") List<PcOutListDetail> updateList);

    /**
     * 更新外发号码明细单号
     * @param numberList
     */

    @Update({
            "<script>",
            "<foreach item='t' collection='numberList' separator=';'>",
            "update PC_OUT_LIST_DETAIL_SIZE set SLIP_NO=#{slipNo} where LOT_NO=#{t.lotNo}and PART_NAME=#{t.partName} and REQ_NO=#{t.reqNo}",
            "</foreach>",
            "</script>"
    })
    void updatePcOutListDetailSize(@Param("numberList") List<OutGoingNumberQueryRequest> numberList, String slipNo);

    /**
     * 根据id去查询
     * @param slipNo
     */
    @Select("select ID,LOT_NO,STYLE,COLOR,PART_NAME,PUR_QTY,SLIP_NO,PUR_DATE,VENDOR,DELIVERY_DATE,PRICE,AMT,PUR_MEMO,CFM_FLAG,REQ_NO,PROCESS from PC_OUT_LIST_DETAIL " +
            "where SLIP_NO=#{slipNo}")
    List<PcOutListDetailDto> getPcOutListDetail(String slipNo);

    /**
     * 整个加工单删除
     * @param slipNo
     */
    @Delete("delete from PC_OUT_LIST_DETAIL where SLIP_NO=#{slipNo}")
    void delPcOutListDetail(String slipNo);

    /**
     * 删除外发号码明细
     * @param pcOutListDetailDto
     */
    @Delete({
            "<script>",
            "delete from PC_OUT_LIST_DETAIL_SIZE where (LOT_NO, PART_NAME, REQ_NO, SLIP_NO) in ",
            "<foreach item='t' collection='list' open='(' separator=',' close=')'>",
            "(#{t.lotNo}, #{t.partName}, #{t.reqNo}, #{t.slipNo})",
            "</foreach>",
            "</script>"
    })
    void delPcOutListDetailSize(@Param("list") List<PcOutListDetailDto> pcOutListDetailDto);

    /**
     * 查询可外发的指令信息
     * @param lotNo
     * @param companyId
     */
    @Select("SELECT t.LOT_NO,t.STYLE,t.COLOR,t.COMPANY_ID,t1.PART_NAME,t1.SEQ_NO,CASE WHEN t2.S_SURPLUS_FLAG='Y' THEN 1 ELSE 0 END as subSurplusFlag," +
            "CASE WHEN CASE WHEN t2.S_SURPLUS_FLAG='Y' THEN 1 ELSE 0 END = 0 THEN COALESCE(t.ORDER_QTY, 0)  + COALESCE(t.SURPLUS_QTY, 0)ELSE t.ORDER_QTY END AS totalQty," +
            "t1.VENDOR,t1.PUR_DATE,t1.PRICE,t1.PUR_MEMO from PC_LOT_HEAD t left JOIN PC_OUT_LIST_PRICE t1  on t.LOT_NO=t1.LOT_NO and t.COMPANY_ID=t1.COMPANY_ID and t.STYLE=t1.STYLE " +
            "RIGHT JOIN PC_OUT_LIST t2 on t.COMPANY_ID=t2.COMPANY_ID and t1.PART_NAME=t2.PART_NAME where  t1.CHECK_FLAG='Y' AND t1.LOT_NO=#{lotNo} and t.COMPANY_ID=#{companyId}")
    List<PcLotOutListDto> getInstructionOutsourcing(String lotNo, String companyId);

    /**
     * 查询外发工艺部位
     *
     * @param lotNo
     * @param code
     * @param companyId
     */
    @Select({
            "SELECT t2.ORDER_QTY as totalQty,t2.DEVELOPMENT_NO,t1.LOT_NO,t1.STYLE,t1.COLOR,t1.SEQ_NO,t1.PROCESS,t1.PART_NAME,t1.CUT_NUM,t1.VENDOR,t1.PUR_DATE,t1.PRICE,t1.PUR_MEMO" +
                    " from (SELECT PROCESS from PC_CUTTING_PROCESS_DETAIL where PROCESS_CODE=#{code})t " +
                    " LEFT JOIN PC_OUT_LIST_PRICE t1 on t.PROCESS=t1.PROCESS LEFT JOIN PC_LOT_HEAD t2 on t1.LOT_NO=t2.LOT_NO " +
                    "where t1.CHECK_FLAG='Y' and t1.LOT_NO=#{lotNo} and t1.COMPANY_ID=#{companyId}",
    })
    List<PcLotOutListDto> getPartProcess(@Param("lotNo") String lotNo, @Param("code") String code, @Param("companyId") String companyId);

    /**
     * 查询外发工艺号码明细
     * @param lotNo 指令
     * @param partName 部位
     * @param process 工艺
     */
    @Select("SELECT t.PROCESS,t1.LOT_NO,t1.STYLE,t2.SEQ_NO,t2.SIZE_NO,t3.CUT_SIZE,t2.ORDER_QTY,t2.SURPLUS_QTY,t1.PART_NAME,t5.QTY AS outQty " +
            "from (SELECT PROCESS from PC_CUTTING_PROCESS_DETAIL where PROCESS_CODE=#{code})t LEFT JOIN PC_OUT_LIST_PRICE t1 on t.PROCESS=t1.PROCESS " +
            "LEFT JOIN PC_LOT_DETAIL t2 on t1.LOT_NO=t2.LOT_NO LEFT JOIN SD_STYLE_SIZE t3 on t3.SIZE_NO=t2.SIZE_NO and t1.STYLE=t3.STYLE_NO and t2.COMPANY_ID=t3.COMPANY_ID " +
            "LEFT JOIN (SELECT SIZE_NO,LOT_NO,PROCESS,PART_NAME,SEQ_NO,SUM(QTY) AS QTY from PC_OUT_LIST_DETAIL_SIZE GROUP BY SIZE_NO,LOT_NO,PROCESS,PART_NAME) t5 " +
            "on t1.LOT_NO=t5.LOT_NO and t1.PROCESS=t5.PROCESS and t5.SIZE_NO=t2.SIZE_NO and REPLACE(t1.PART_NAME, t1.PROCESS, '')=t5.PART_NAME " +
            "where t1.LOT_NO=#{lotNo} and t1.PROCESS=#{process} and t1.PART_NAME=#{partName} ORDER BY t1.PART_NAME,t1.LOT_NO,t2.SEQ_NO asc")
    List<PcOutSizeListDto> getSizeDetailList2(@Param("lotNo") String lotNo,@Param("partName") String partName,@Param("process") String process,@Param("code") String code);

    /**
     * 查询补料单号
     * @param lotNo
     * @param slipNo
     */
    @Select({
            "<script>",
            "SELECT b.SLIP_NO as style,b.LOT_NO from PC_SUPPLEMENT_HEAD a LEFT JOIN(SELECT LOT_NO,SLIP_NO  from PC_SUPPLEMENT_DETAIL GROUP BY LOT_NO,SLIP_NO) b on a.SLIP_NO=b.SLIP_NO",
            "<where>",
            "b.LOT_NO is not null and a.FINANCE_FLAG='Y'",
            "<if test='lotNo!=null and !lotNo.isEmpty()'>",
            " and b.LOT_NO LIKE concat('%',#{lotNo},'%')",
            "</if>",
            "<if test='slipNo!=null and !slipNo.isEmpty()'>",
            "and b.SLIP_NO LIKE concat('%',#{slipNo},'%')",
            "</if>",
            "</where>",
            "</script>"
    })
    List<PcLotHeadListDto> getSlipNoList(String lotNo, String slipNo);

    /**
     * 查询补单外发加工项目
     *
     * @param lotNo
     * @param companyId
     * @return
     */
    @Select("SELECT t.SEQ_NO,t.LOT_NO,t.STYLE,t.COLOR,t.PART_NAME,t.VENDOR,t.PUR_DATE,t.PRICE,t.CUT_NUM,t.PROCESS,t.PUR_MEMO " +
            "from PC_OUT_LIST t2 left JOIN PC_OUT_LIST_PRICE t on t.COMPANY_ID=t2.COMPANY_ID and t.PART_NAME=t2.PART_NAME " +
            "where  t.CHECK_FLAG='Y' AND t.LOT_NO=#{lotNo} and t.COMPANY_ID=#{companyId}" +
            " and not EXISTS (SELECT 1 from PC_OUT_LIST_DETAIL where LOT_NO=t.LOT_NO and REQ_NO=#{reqNo} and PART_NAME=t.PART_NAME)")
    List<PcLotOutListDto> getOutPartName(String lotNo, String companyId,String reqNo);

    /**
     * 查询补单数量
     * @param lotNo
     * @param slipNo
     * @return
     */
    @Select("SELECT * from PC_SUPPLEMENT_DETAIL where SLIP_NO=#{slipNo} and LOT_NO=#{lotNo}  ORDER BY TOTAL_QTY DESC LIMIT 1")
    PcSupplementDetail getSlipNoOrderQty(String lotNo, String slipNo);

    /**
     * 获取补单号码明细
     * @param lotNo
     * @param slipNo
     * @param seqNo 序号
     */
    @Select("SELECT DISTINCT t1.SEQ_NO,t1.SIZE_NO,t1.SIZE_SEQ as cutSize,t1.LOT_NO,t2.QTY as orderQty from PC_SUPPLEMENT_SIZE t1 LEFT JOIN " +
            " (SELECT SIZE_NO,LOT_NO,PROCESS,PART_NAME,SEQ_NO,SUM(QTY) AS QTY,REQ_NO from PC_OUT_LIST_DETAIL_SIZE where REQ_NO=#{slipNo} and PART_NAME=#{partName} GROUP BY SIZE_NO,LOT_NO,PROCESS,PART_NAME)t2 " +
            " on t1.LOT_NO=t2.LOT_NO and t1.SIZE_NO=t2.SIZE_NO and t2.REQ_NO=t1.SLIP_NO " +
            "where t1.SLIP_NO=#{slipNo} and t1.LOT_NO=#{lotNo} and t1.PART_SEQ_NO=#{seqNo}")
    List<PcOutSizeListDto> getPcSupplementSize(String lotNo, String slipNo, Integer seqNo,String partName);

    /**
     * 查询补单外发部位工艺明细
     * @param lotNo
     * @param slipNo
     * @return
     */
    @Select("SELECT t1.SEQ_NO,t1.LOT_NO,t1.STYLE,t1.COLOR,t.PROCESS,t1.PART_NAME,t1.VENDOR,t1.PUR_DATE,t1.PRICE,t1.CUT_NUM,t1.PUR_MEMO,t2.SLIP_NO as reqNo,t2.ORD_QTY as totalQty from " +
            "(SELECT PROCESS from PC_CUTTING_PROCESS_DETAIL)t LEFT JOIN PC_OUT_LIST_PRICE t1 on t.PROCESS=t1.PROCESS LEFT JOIN (SELECT LOT_NO,SLIP_NO,ORD_QTY,PART_NAME  " +
            "from PC_SUPPLEMENT_DETAIL GROUP BY LOT_NO,SLIP_NO,ORD_QTY,PART_NAME) t2 " +
            "on t1.LOT_NO=t2.LOT_NO and REPLACE(t1.PART_NAME, t1.PROCESS, '')=t2.PART_NAME " +
            "WHERE t1.LOT_NO=#{lotNo} and t2.SLIP_NO=#{slipNo} and t1.CHECK_FLAG='Y'")
    List<PcLotOutListDto> getSilpProcessList(String lotNo, String slipNo);

    /**
     * 查询补单数量明细
     * @param lotNo
     * @param slipNo
     * @param partName
     * @return
     */
    @Select("SELECT * from PC_SUPPLEMENT_DETAIL where SLIP_NO=#{slipNo} and LOT_NO=#{lotNo} and PART_NAME=#{partName}")
    List<PcSupplementDetail> getSlipNoOrderQty2(String lotNo, String slipNo, String partName);

    /**
     * 根据部位查询号码明细
     * @param lotNo
     * @param slipNo
     * @param seqNo
     * @param partName
     * @return
     */
    @Select("SELECT t1.SEQ_NO,t1.SIZE_NO,t1.SIZE_SEQ as cutSize,t1.LOT_NO,t2.QTY as orderQty from PC_SUPPLEMENT_SIZE t1 LEFT JOIN " +
            " (SELECT SIZE_NO,LOT_NO,PROCESS,PART_NAME,SEQ_NO,SUM(QTY) AS QTY from PC_OUT_LIST_DETAIL_SIZE WHERE PART_NAME=#{partName} GROUP BY SIZE_NO,LOT_NO,PROCESS,PART_NAME)t2 " +
            " on t1.LOT_NO=t2.LOT_NO and t1.SIZE_NO=t2.SIZE_NO " +
            "where t1.SLIP_NO=#{slipNo} and t1.LOT_NO=#{lotNo} and t1.PART_SEQ_NO=#{seqNo}")
    List<PcOutSizeListDto> getPcSupplementSize2(String lotNo, String slipNo, Integer seqNo,String partName);

}
